package com.example.tests;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

import java.util.Random;

import org.testng.annotations.Test;

import com.example.utils.SortedListOf;

public class GroupModificationTests extends TestBase{
	
	@Test (dataProvider = "randomValidGroupGenerator")
	public void modifySomeGroup(GroupData group){
		
		//save old groups list
		SortedListOf<GroupData> oldGroups = app.getGroupHelper().getGroups();
				
		//modify some group		
		Random rnd = new Random();
		int index = rnd.nextInt(oldGroups.size()-1);
		app.getGroupHelper().modifyGroup(index, group);
		
		//save new groups list
		SortedListOf<GroupData> newGroups = app.getGroupHelper().getGroups();
		
		//compare lists
		assertThat(newGroups, equalTo(oldGroups.without(index).withAdded(group)));	
	}

}
